#ifndef __GE_TEXTUREOBJ_H__
#define __GE_TEXTUREOBJ_H__

#include "GE_Base.h"

namespace Syp
{
struct TexOptions
{
	TextureObj* tex;
	bool buildMipMaps;
	bool compressTextures;
	String filename;

};

///TextureObj stores information of a texture. The file it is loaded from, number of MeshInstances using it, it's id.
class TextureObj : public Resource
{	
	friend class Renderer;
public:
	TextureObj(const String& filename);	
	///Loads a texture and returns a pointer to a TextureObj.
	static TextureObj* loadTexture(const String& filename,bool buildMipMaps = true,bool compressTextures = true, bool async = true); ///	duh
	///Loads a texture from memory,
	///name specifies desired name for the object
	///TexOptions is a pointer to a TexOptions structure defining properties of the texture
	///width and height define the width and height of the texture
	///data contains the bitmap information
	///format contains the format of the image data
	static TextureObj* loadFromMemory(TexOptions* to, PInt width, PInt height, unsigned char* data, Syp::TextureFormat format, Syp::TextureFormat internalFormat);
	virtual void dumpResourceInfo();
	PInt getWidth();
	PInt getHeight();
private:	
	//Multi-threaded function which loads actual file in another thread.
	static void doLoad(void* arg);
	//static void _stdcall doLoad(void* arg);
	///ID used by OpenGL to recognise the texture
	PInt id;	
	friend struct SubMaterial;
	/*friend void SubMaterial::useTexture(TextureObj* txtID);
	friend void SubMaterial::clearTexture();*/
	PInt width;
	PInt height;
	TextureFormat format;
	TextureFormat internalFormat;
	bool hasMipMaps;
	~TextureObj();

};
}

#endif //__GE_TEXTUREOBJ_H__

